using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyKTV
{
    //播放列表
    class SongList
    {
        //保存歌曲的数组
        private static Song[] list=new Song[1000];
        //已经点歌的个数
        private static int size = 0;
        //当前正在播第几首歌曲，0表示为还没开始播放
        private static int playIndex = 0;

        //获得当前的播放列表

        public static int getPlayIndex()
        {
            return playIndex;
        }

        /*获取播放列表长度*/
        public static int getSize()
        {
            return size;
        }

        //获得列表
        public static Song[] getList()
        {
            return list;
        }

        //获得当前播放的歌曲
        public static Song getPlayingSong()
        {
            if (playIndex == 0)
            {
                Console.WriteLine("没有播放");
                return null;
            }
            return list[playIndex - 1];
        }

        //增加一首歌曲
        public static void addSong(Song song)
        {
            if (size == 1000)
            {
                //满了
                Console.WriteLine("播放列表满了");
                return;
            }           
            list[size] = song;
            size++;
        }

        //获得下一首歌曲
        public static Song next()
        {
            if (playIndex == size ||playIndex == 1000)
            {
                Console.WriteLine("播放完了");
                return null;
            }
            Song song=list[playIndex];
            playIndex++;
            return song;
        }

        //获得上一首歌曲
        public static Song piror()
        {
            if (playIndex ==0)
            {
                Console.WriteLine("播放列表为空");
                return null;
            }

            Song song = list[playIndex-1];
            playIndex--;
            return song;
        }
    }
}
